<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:insert="~{common/comm_blocks :: comm_header(title=~{::title}, links=~{::link}, scripts=~{::head_scripts/script})}">
    <title>登录页面</title>
    <th:block th:fragment="head_scripts">
        <script>
            function generateCaptcha(){
                $.ajax({
                    type: "get",
                    url: "ym/comm/getCaptcha.do",
                    success:function(data){
                        if(successData(data)){
                            data = data.data
                            $('#ipt_captcha_id').val(data.captchaId);
                            $('#img_captcha').attr('src', data.captchaImage);
                        }else{
                            $('#ipt_captcha_id').val('');
                            $('#img_captcha').attr('src', '');
                            alert("验证码获取失败");
                        }
                    }
                });
            }
        </script>
    </th:block>
</head>
<body>
<form th:action="${loginAction}" method="post">
    <input type="hidden" th:name="${_csrf?.parameterName?:'_'}" th:value="${_csrf?.token?:'_'}"/>
    <div>
        <label>
            用户名：
            <input type="text" th:name="${usernameParameter}"/>
        </label>
    </div>
    <div>
        <label>
            密码：
            <input type="password" th:name="${passwordParameter}"/>
        </label>
    </div>
    <div>
        <label>
            客户端：
            <select id="clientType" name="clientType">
                <option value="100">桌面端</option>
                <option value="201">安卓</option>
                <option value="202">IOS</option>
            </select>
        </label>
    </div>
    <div>
        <label>
            记住我：
            <input type='checkbox' th:name="${rememberMeParameter}"/>
        </label>
    </div>
    <div>
        <label>验证码：
            <input type="text" th:name="${captchaParameter}"/>
            <img style='display:block; width:120px;height:40px;' src="" id='img_captcha' alt=""/>
            <input type="hidden" id="ipt_captcha_id" th:name="${captchaIdParameter}"/>
            <input type="button" onclick="generateCaptcha()" value="刷新验证码"/>
        </label >
    </div>

    <input type="submit" value="登录"/>

    <h3>============OAuth2登录============</h3>
    <table>
        <tr>
            <td>
                <a th:href="@{/oauth2/authorization/github}">GitHub</a>
            </td>
        </tr>
        <tr>
            <td>
                <a th:href="@{/oauth2/authorization/gitee}">gitee</a>
            </td>
        </tr>
    </table>
</form>
</body>
</html>
